<?php

class BaseAction extends CAction
{
    public $template      = null;
    public $renderPartial = false;
    public $isReturnUrl   = false;
    public $isRender      = true;
    public $pageId        = '';


    public function __construct($controller, $id)
    {
        parent::__construct($controller, $id);
        
        $this->template = new Template;

        $oTheme = Yii::app()->getTheme();

        $this->template->resourceUrl    = $oTheme->resourceUrl = $oTheme->themesUrl.'/resources/';
        $this->template->themeUrl       = $oTheme->themeUrl    = $oTheme->baseUrl.'/';
        $this->template->themeImgUrl    = $oTheme->imgUrl      = $this->template->themeUrl.'images/';
        $this->template->themeCssUrl    = $oTheme->cssUrl      = $this->template->themeUrl.'css/';
        $this->template->themeJsUrl     = $oTheme->jsUrl       = $this->template->themeUrl.'js/';
        $this->template->controllerName = Yii::app()->controller->id;
        $this->template->actionName     = $this->id;
        
        Yii::app()->user;

        if (!$this->pageId)
        {
            $this->pageId = $this->id;
        }

        $oContent = Page::model()->getPageByAlias($this->pageId);
        $sPageDefaultMeta = Yii::app()->params['default_meta'];

        Yii::app()->name .= ($oContent && $oContent->page_title)?' - '.$oContent->page_title:($sPageDefaultMeta['title']?' - '.$sPageDefaultMeta['title']:'');
        Yii::app()->clientScript->registerMetaTag('text/html; charset=utf-8', null, 'Content-Type');
        Yii::app()->clientScript->registerMetaTag(($oContent && $oContent->page_keywords)?$oContent->page_keywords:$sPageDefaultMeta['keywords'], 'keywords');
        Yii::app()->clientScript->registerMetaTag(($oContent && $oContent->page_description)?$oContent->page_description:$sPageDefaultMeta['description'], 'description');

        $this->template->oContent = $oContent;
    }

    public function run()
    {
    }
}